package com.jiang5sx.partnermatching.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
@EnableOpenApi
public class SwaggerConfig {

    @Value("${springfox.documentation.swagger-ui.enabled}")//swagger开关
    Boolean swaggerEnabled;

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(defaultApiInfo())
                .enable(swaggerEnabled)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.jiang5sx.partnermatching.controller"))//controller包路径
                .build();
    }

    private ApiInfo defaultApiInfo(){
        Contact contact = new Contact("吴江", "", "jiang5sx@foxmail.com");
        return new ApiInfo(
                "用户中心系统",
                "某某系统接口文档",
                "v1.0",
                "http://127.0.0.1:8080",
                contact,
                "Apache2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>()
        );
    }
}
